package com.sgb.kjwl.view.widget;

import android.content.Context;
import androidx.databinding.DataBindingUtil;
import androidx.annotation.Nullable;
import android.text.TextUtils;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.widget.LinearLayout;

import com.sgb.kjwl.R;
import com.sgb.kjwl.databinding.MapInfoWindow4Binding;
import com.sgb.kjwl.model.entity.supplier3.SupplierRecommendEntity;

/**
 * Description:
 * Author zhengkewen
 * Time 2018/8/20
 */
public class MapInfoWindow4 extends LinearLayout {

    protected Context mContext;
    protected MapInfoWindow4Binding viewBinding;
    private SupplierRecommendEntity entity;

    public MapInfoWindow4(Context context) {
        this(context, null);
    }

    public MapInfoWindow4(Context context, @Nullable AttributeSet attrs) {
        this(context, attrs, 0);
    }

    public MapInfoWindow4(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
        this(context, attrs, defStyleAttr, 0);
    }

    public MapInfoWindow4(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
        super(context, attrs, defStyleAttr);
        this.mContext = context;
        initView();
    }

    private void initView() {
        viewBinding = DataBindingUtil.inflate(LayoutInflater.from(mContext), R.layout.map_info_window4, this, true);
    }

    public void setData(SupplierRecommendEntity entity) {
        this.entity = entity;
        viewBinding.titleView.setText(entity.getName());
        if (!TextUtils.isEmpty(entity.getAuthYear())) {
            viewBinding.tvAuthYear.setVisibility(VISIBLE);
            viewBinding.tvAuthYear.setText(entity.getAuthYear());
        }else{
            viewBinding.tvAuthYear.setVisibility(GONE);
        }
        viewBinding.tvAddress.setText(entity.getAddress());
        viewBinding.tvDistance.setText(entity.getDistance());
        viewBinding.companyView.setText(entity.getMainBusiness());
    }

    public SupplierRecommendEntity getData() {
        return entity;
    }
}
